/**
 * Copyright (c) 2009 Collaborative Development Group, C.S. Dept., University of Bari
 *
 * All rights reserved. This program and the accompanying materials are made available under
 * the terms of the Eclipse Public License v1.0  which accompanies this distribution, and is 
 * available at http://www.eclipse.org/legal/epl-v10.html
 */
package it.uniba.di.cdg.penelope.ui;

import static com.google.inject.name.Names.named;
import it.uniba.di.cdg.penelope.ui.mvp.scope.ViewScope;
import it.uniba.di.cdg.penelope.ui.mvp.scope.ViewScoped;
import it.uniba.di.cdg.penelope.ui.swt.SWTThreadInterceptor;

import org.eclipse.swt.widgets.Display;

import com.google.inject.AbstractModule;

/**
 * Provides the basic configuration for Eclipse workbench (i.e., {@link Display} reference) and 
 * UI-Thread synchronization (see {@link SWTThreadInterceptor}).
 * <br/>
 * This configuration extends {@link EclipseSupportConfig}.
 */
public class CommonUIConfig extends AbstractModule {
	/* (non-Javadoc)
	 * @see com.google.inject.AbstractModule#configure()
	 */
	@Override
	protected void configure() {
		install( new EclipseSupportConfig() );

		// View Scope support
		ViewScope viewScope = new ViewScope();
		bindScope( ViewScoped.class, viewScope );
		bind( ViewScope.class ).annotatedWith( named( "viewScope" ) ).toInstance( viewScope );
		
//		SWTThreadInterceptor swtThreadingInterceptor = new SWTThreadInterceptor();
//		requestInjection( swtThreadingInterceptor );
//		bindInterceptor( Matchers.any(), Matchers.annotatedWith( SWTSyncExec.class ), swtThreadingInterceptor );
//
//		JobExecutorInterceptor jobInterceptor = new JobExecutorInterceptor();
//		requestInjection( jobInterceptor );
//		bindInterceptor( Matchers.any(), Matchers.annotatedWith( RunAsJob.class ), jobInterceptor );
	}
}
